package com.gzhryc.weixin.api.event;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang3.StringUtils;

public class EventUtils {
	
	static Pattern eventKeyPat = Pattern.compile("^qrscene_(.*)$");

	public static Integer getIntKey(String eventKey){
		Matcher mat = eventKeyPat.matcher(eventKey);
		if(mat.find()){
			String val = mat.group(1);
			if(StringUtils.isNotBlank(val) && StringUtils.isNumeric(val)){
				return Integer.valueOf(val);
			}
		}
		return null;
	}
	
	public static String getStringKey(String eventKey){
		Matcher mat = eventKeyPat.matcher(eventKey);
		if(mat.find()){
			String val = mat.group(1);
			return val;
		}
		return null;
	}
}
